package com.rerun.common.bean;

import java.io.Serializable;
import java.util.Collection;
import java.util.List;

/**
 * The type Quartz return t.
 *
 * @author dax.
 * @version v1.0
 * @since 2017 /10/30 9:24
 */
public class QuartzReturnT implements Serializable {

    private static final long serialVersionUID = -3435018522613486959L;

    private int code;
    private String msg="";
    private int count;
    private Collection data;

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public int getCount() {
        return count;
    }

    public void setCount(int count) {
        this.count = count;
    }

    public Collection getData() {
        return data;
    }

    public void setData(Collection data) {
        this.data = data;
    }

    /**
     * Ok data quartz return t.
     *
     * @param list the list
     * @return the quartz return t
     */
    public static QuartzReturnT okData(Collection list) {
        QuartzReturnT quartzReturnT = new QuartzReturnT();
        if (list != null) {
            quartzReturnT.setCount(list.size());
        } else {
            quartzReturnT.setCount(0);
        }
        quartzReturnT.setData(list);
        return quartzReturnT;
    }

    /**
     * Ok data quartz return t.
     *
     * @param list the list
     * @param msg  the msg
     * @return the quartz return t
     */
    public static QuartzReturnT okData(List list, String msg) {
        QuartzReturnT quartzReturnT = new QuartzReturnT();
        quartzReturnT.setMsg(msg);
        if (list != null) {
            quartzReturnT.setCount(list.size());
        } else {
            quartzReturnT.setCount(0);
        }
        quartzReturnT.setData(list);
        return quartzReturnT;
    }
}
